import Router from 'vue-router'
Vue.use(Router)


// 解决编程式路由往同一地址跳转时会报错的情况
const originalPush = Router.prototype.push;
const originalReplace = Router.prototype.replace;

// push
Router.prototype.push = function push(location, onResolve, onReject) {
  if (onResolve || onReject)
    return originalPush.call(this, location, onResolve, onReject);
  return originalPush.call(this, location).catch(err => err);
};

//replace
Router.prototype.replace = function push(location, onResolve, onReject) {
  if (onResolve || onReject)
    return originalReplace.call(this, location, onResolve, onReject);
  return originalReplace.call(this, location).catch(err => err);
};


export default new Router({
	mode: 'history',
	base: '/sys',
	routes: [
    {
      path: '/',
      redirect:'/dianpu'
    },
    {
        path: '/login',
        component: () => import('@/admin/login'),
        mete:{
          title:"注册登录",
        }
    },
    //店铺管理
    {
    	path: '/dianpu',
      component: () => import('@/admin/dianpu/index'),
      redirect:'/dianpu/dianpuguanli',
      children:[
        {
          path: '/dianpu/dianpuguanli',
          component: () => import('@/admin/dianpu/dianpuguanli'),
          mete:{
            title:"店铺管理",
          },
        },
      ]
    },
    //签名管理
    {
    	path: '/qianming',
      component: () => import('@/admin/qianming/index'),
      redirect:'/qianming/qianmingguanli',
      children:[
        {
          path: '/qianming/qianmingguanli',
          component: () => import('@/admin/qianming/qianmingguanli'),
          mete:{
            title:"签名管理",
          },
        },
      ]
    },
    //系统更新通知
    {
    	path: '/tongzhi',
      component: () => import('@/admin/tongzhi/index'),
      redirect:'/tongzhi/tongzhi',
      children:[
        {
          path: '/tongzhi/tongzhi',
          component: () => import('@/admin/tongzhi/tongzhi'),
          mete:{
            title:"签名管理",
          },
        },
      ]
    }
	]
})
